﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PSE.Framework.ErrorLogging;
using System.Xml.Serialization;
using System.Xml;

namespace Sinacor.Infra.Common.ErrorLogging
{
    public abstract class UserNameEnvironmentData : DbEnvironmentData
    {
        [XmlAttribute]
        public string SinacorUserName { get; set; }

        protected override string ToStringOverride()
        {
            StringBuilder logData = new StringBuilder(base.ToStringOverride());

            if (!string.IsNullOrEmpty(this.SinacorUserName))
            {
                logData.AppendFormat("SinacorUserName:\t{0}", this.SinacorUserName);
                logData.AppendLine();
            }

            return logData.ToString();
        }

        public override void WriteTo(XmlWriter writer)
        {
            base.WriteTo(writer);

            if (!string.IsNullOrEmpty(this.SinacorUserName))
            {
                writer.WriteElementString("SinacorUserName", this.SinacorUserName);
            }
        }
    }
}
